//1.引入Vue
import Vue from "vue";
//2.引入VueRouter
import VueRouter from "vue-router";
//3.使用VueRouter
Vue.use(VueRouter)

//引入路由组件
import Loagin from '../pages/Loagin/Loagin.vue'
import Home from '../pages/Home/Home.vue'
//引入home子路由
import Music from '../pages/Home/Music/Music.vue'
import Games from '../pages/Home/Games/Games.vue'
import Subject from '@/pages/Home/SubJect/Subject'
export default new VueRouter({
  routes: [
    //默认路由
    {
      path: '/',
      redirect: '/home'
    }, {
      path: '/home',
      component: Home,
      //子路由
      children: [{
        name: 'Subject',
        path: "subject",
        component: Subject,
        props(state) {
          return {
            ...state.query
          }
        }
      }, {
        name: 'music',
        path: 'music/:id',
        component: Music,
        //开启props 便捷接收参数
        props: true
      }, {
        name: 'Games',
        path: 'Games',
        component: Games,
        meta: {
          isLove: true,
        },
        //使用props函数模式 返回query参数
        props(route) {
          return {
            ...route.query,
            ...route.meta
          }
        }
      }]
    },
    {
      path: '/Loagin',
      component: Loagin
    }
  ]
})